#include <iostream>
#include <algorithm>

int const maxn = 107;
int a[maxn][maxn];
int f[maxn][maxn];
int n;

int main()
{
	std::ios::sync_with_stdio(false);
	std::cin >> n;
	for (int i = 1; i <= n; i++)
		for (int j = 1; j <= i; j++) std::cin >> a[i][j];
	for (int i = 1; i <= n; i++)
		for (int j = 1; j <= i; j++) {
			f[i + 1][j] = std::max(f[i + 1][j], f[i][j] + a[i][j]);
			f[i + 1][j + 1] = std::max(f[i + 1][j + 1], f[i][j] + a[i][j]);
		}
	int ans = 0;
	for (int i = 1; i <= n; i++)
		ans = std::max(ans, f[n][i] + a[n][i]);
	std::cout << ans << '\n';
}

